hook::add message bot:messages 105
proc bot:messages {from type body} {

	set a bot:answer
	if {[config::optionenable talk]} {
		if { $type=="error" } {
			putlog "error type \n $body"
			return
		}
		set a [user_from_jid $from]
		set name [config::name $a]
		if { [resource_from_jid "$from"]=="$name"} {
			::debug $a "nick($a)==name($a)($name)" "message by me.not answered"
			putlog "==============================>message BY me"
			hook::run mymessage "$from" "$type" "$body"
			return stop
		}
		if {[cmd "$body" "$name"] || $type=="chat"} {
			putlog "==============================>message TO me"
			set beg [string length "$name"]
			set body "[string range $body $beg end]"
			if {[string range $body 0 1]==": "} {
				set body "[string range $body 2 end]"
			}
			#string trimleft $body
			hook::run messagetome "$from" "$type" "$body"
			return stop
		}
		
	}
}